package com.wgl.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.wgl.cmn.mapper.DictMapper;
import com.wgl.model.dict.Dict;
import com.wgl.model.vo.cmn.DictVo;
import org.springframework.beans.BeanUtils;

/**
 * @author wgl
 * @version 1.0.0
 * @ClassName DictListener.java
 * @Description alibaba.easyexcel 的读取Excel监听器
 * @createTime 2022年02月05日 11:18:00
 */
public class DictListener extends AnalysisEventListener<DictVo> {
    private DictMapper mapper;

    public DictListener(DictMapper mapper) {
        this.mapper = mapper;
    }

    //读完一行进行的操作
    @Override
    public void invoke(DictVo dictVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictVo,dict);
        mapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
